Public Function DistancePointToPoint(ByVal x1 As Single, ByVal y1 As Single, ByVal z1 As Single, ByVal x2 As Single, ByVal y2 As Single, ByVal z2 As Single) As Single
Dim dx As Single
Dim dy As Single
Dim dz As Single
dx = x2 - x1
dy = y2 - y1
dz = z2 - z1
DistancePointToPoint = Sqr(dx * dx + dy * dy + dz * dz)
End Function
' Return the distance between a point and a line.
Public Function DistancePointToLine(ByVal x1 As Single, ByVal y1 As Single, ByVal z1 As Single, ByVal x2 As Single, ByVal y2 As Single, ByVal z2 As Single, ByVal vx2 As Single, ByVal vy2 As Single, ByVal vz2 As Single) As Single
' Return the distance between a point and a plane.
Public Function DistancePointToPlane(ByVal x1 As Single, ByVal y1 As Single, ByVal z1 As Single, ByVal x2 As Single, ByVal y2 As Single, ByVal z2 As Single, ByVal nx2 As Single, ByVal ny2 As Single, ByVal nz2 As Single) As Single
Dim ax As Single
Dim ay As Single
Dim az As Single
Dim a_dot_n As Single
Dim len_n As Single
ax = x2 - x1
ay = y2 - y1
az = z2 - z1
a_dot_n = ax * nx2 + ay * ny2 + az * nz2
len_n = Sqr(nx2 * nx2 + ny2 * ny2 + nz2 * nz2)
DistancePointToPlane = Abs(a_dot_n / len_n)
End Function
' Return the distance between two lines.
Public Function DistanceLineToLine(ByVal x1 As Single, ByVal y1 As Single, ByVal z1 As Single, ByVal x2 As Single, ByVal y2 As Single, ByVal z2 As Single, ByVal vx1 As Single, ByVal vy1 As Single, ByVal vz1 As Single, ByVal vx2 As Single, ByVal vy2 As Single, ByVal vz2 As Single) As Single